package com.onLineCar.management.domain;


import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

@Data
public class DispatchVehicleRequest {
    private UserDTO userDTO;
    private OrderDTO orderDTO;

    public DispatchVehicle convertDispatchVehicle(DispatchVehicleRequest dispatchVehicleRequest, Integer status) {
        UserDTO userDTO = dispatchVehicleRequest.getUserDTO();
        OrderDTO orderDTO = dispatchVehicleRequest.getOrderDTO();
        DispatchVehicle dispatchVehicle = new DispatchVehicle().setEndPoint(PointConvertStringUtil.convertPointToString(userDTO.getEndPoint()))
                .setOrderNum(orderDTO.getOrderNum())
                .setOrderTime(orderDTO.getOrderTime())
                .setOrderType(orderDTO.getOrderType())
                .setUserId(userDTO.getUserId())
                .setStartPoint(PointConvertStringUtil.convertPointToString(userDTO.getStartPoint()))
                .setStartPlace(userDTO.getStartPlace())
                .setEndPlace(userDTO.getEndPlace())
                .setUseCarTime(orderDTO.getUseCarTime());
        if (ObjectUtils.isNotEmpty(status)){
            dispatchVehicle.setStatus(status);
        }
        return dispatchVehicle;
    }
}
